#set($serviceClass=${strUtil.au($object)}+'Service')
#set($serviceVar=${strUtil.al($object)}+'Service')
#set($objectName=${strUtil.au($object)})
#set($paramName=${strUtil.au($object)}+'Param')

package ${group}.${artifact}.${module}.action;


import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import ${group}.core.page.RemotePage;
import ${group}.core.rest.annotation.RestApi;
import ${group}.core.rest.annotation.Delete;
import ${group}.core.rest.annotation.Get;
import ${group}.core.rest.annotation.Post;
import ${group}.core.rest.annotation.Put;
import ${group}.core.rest.support.ParamModal;
import ${group}.core.rest.support.RestActionSupporter;

import ${group}.${artifact}.${module}.dto.${objectName};
import ${group}.${artifact}.${module}.dto.${paramName};
import ${group}.${artifact}.${module}.service.${serviceClass};
	
@RestApi("${ctxPath}")
public class ${objectName}Action extends RestActionSupporter{
	
	@Autowired
	private ${serviceClass} ${serviceVar};
	
	private int getUserId(){
		return 0 ;
	}
	
#if(  ${apis.get("find")} &&  ${apis.get("find").enabled} )
	@Get
	public String find${objectName}( ParamModal modal ){
		Map<String,Object> param = modal.getParam("id") ;
		RemotePage<${objectName}> pageData =${serviceVar}.findList( param , 
			modal.getPageParam(), ${objectName}.class ) ;
		return success( pageData , pageData == null? 0 : pageData.getTotal() ) ;
	}
#end
#if(  ${apis.get("create")} &&  ${apis.get("create").enabled} )
	@Post
	public String create${objectName}( @RequestBody ${paramName} param ){
		param.setCreateId( getUserId() );
		return success( ${serviceVar}.create${objectName}(param) ) ;
	}
#end
#if(  ${apis.get("get")} &&  ${apis.get("get").enabled} )
	@Get("/{id}")
	public String get${objectName}( @PathVariable("id") int id ){
		return success( ${serviceVar}.findBy("id", id, ${objectName}.class ) );
	}
#end
#if(  ${apis.get("update")} &&  ${apis.get("update").enabled} )	
	@Put("/{id}")
	public String update${strUtil.aUpper($objectName)}( @PathVariable("id") int id  ,
			 @RequestBody ${paramName} param ){
		param.setUpdateId( getUserId() );
		${serviceVar}.update${objectName}(id, param);
		return success( null ) ;
	}
#end
#if(  ${apis.get("status")} &&  ${apis.get("status").enabled} )	
	@Put("/{id}/status")
	public String status${objectName}(@PathVariable("id") int id  ){
		${serviceVar}.setStatus(id, getUserId() );
		return success( null ) ;
	}
#end
#if(  ${apis.get("delete")} &&  ${apis.get("delete").enabled} )	
	@Delete("/{id}")
	public String delete${strUtil.aUpper($objectName)}( @PathVariable("id") int id ){
		return success( ${serviceVar}.delete${objectName}(id, getUserId() ) ) ;
	}
#end
}